package com.www.dao;
import java.util.List;

import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.www.domain.RoomType;

/**
 * 房间类型dao
 */
@Repository
public interface RoomTypeDao {
	/*
	 * 房间类型插入操作
	 */
	@Insert("insert into room_type(id,name,photo,price,liveNum,bedNum,roomNum,avilableNum,bookNum,livedNum,status,remark) values(default,#{name},#{photo},#{price},#{liveNum},#{bedNum},#{roomNum},#{avilableNum},#{bookNum},#{livedNum},#{status},#{remark})")
	public int add(RoomType roomType);
	
	/*
	 * 房间类型编辑操作
	 */
	@Update("update room_type set name = #{name},photo = #{photo},price = #{price},liveNum = #{liveNum},bedNum = #{bedNum},roomNum = #{roomNum},avilableNum = #{avilableNum},status = #{status},remark = #{remark} where id = #{id}")
	public int edit(RoomType roomType);
	
	/*
	 * 删除房间类型信息
	 */
	@Delete("delete from room_type where id = ${value}")
	public int delete(Long id);
	
	/*
	 * 房间类型信息搜索查询
	 */
	@Select({"<script> "+
			"select * from room_type " +
			"where 1=1 " +
			"<if test='name != null'> and name like '%${name}%'</if>" +
			"<if test='status != null'> and status like '%${status}%'</if>" +
			"<if test='mobile != null'> and mobile like '%${mobile}%'</if>" +
			"<if test='offset != null and pageSize != null'> limit #{offset},#{pageSize}</if>" +
	 		"</script>"})
	public List<RoomType> findList(Map<String, Object> queryMap);
	
	/*
	 * 模糊搜索总条数
	 */
	@Select({"<script> "+
			"select count(*) from room_type " +
			"where 1=1 " +
			"<if test='name != null'>  and name like '%${name}%'</if>" +
			"<if test='status != null'>  and status like '%${status}%'</if>" +
	 		"</script>"})
	public Integer getTotal(Map<String, Object> queryMap);
	
	/*
	 * 获取所有房间类型信息
	 */
	@Select("select * from room_type")
	public List<RoomType> findAll();
	
	/*
	 * 获取单个房间类型信息
	 */
	@Select("select * from room_type where id = #{value}")
	public RoomType find(Long id);
	
	/*
	 * 房间类型数量编辑操作
	 */
	@Update("update room_type set avilableNum = #{avilableNum},bookNum = #{bookNum},livedNum = #{livedNum} where id = #{id}")
	public int updateNum(RoomType roomType);
}
